/**
 * @Author：ming
 * @Date：2023/9/26 11:33 AM
 * @Filename：Lc205
 */

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;

/**
 * @author ming
 */
public class Lc205 {
    public boolean isIsomorphic(String s, String t) {
        if(s.length()!=t.length()){
            return false;
        }
        HashMap<Character, Character> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            Character c1 = s.charAt(i);
            Character c2 = t.charAt(i);
            if(map.containsKey(c1)){
                if(map.get(c1)==c2){
                    continue;
                }else {
                    return false;
                }
            }else {
                map.put(c1,c2);
            }
        }

        HashMap<Character, Character> map1 = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            Character c1 = t.charAt(i);
            Character c2 = s.charAt(i);
            if(map1.containsKey(c1)){
                if(map1.get(c1)==c2){
                    continue;
                }else {
                    return false;
                }
            }else {
                map1.put(c1,c2);
            }
        }


        return true;
    }
}